package com.hmy.finance.service.receipt.dto.contactorAccount;

import com.hmy.finance.api.common.enums.receipt.AccountTradeBusinessTypeEnum;
import com.hmy.finance.api.common.enums.receipt.AccountTradeTypeEnum;
import com.hmy.finance.dal.po.receipt.CustomerContactorBalanceAccountPo;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 账户流水DTO
 *
 * @author songkf
 */
@Data
public class ContactorTradeDto implements java.io.Serializable {

    private static final long serialVersionUID = 3562307786961180481L;

    //======================= Request Parameters =======================

    /**
     * 联系人余额账户
     */
    private CustomerContactorBalanceAccountPo balanceAccount;

    /**
     * 入账金额
     */
    private BigDecimal amount;

    /**
     * 业务类型
     */
    private AccountTradeBusinessTypeEnum businessType;

    /**
     * 业务单据号
     */
    private Long businessBillId;

    /**
     * 费用发生日期
     */
    private LocalDateTime feeIncurredTime;

    /**
     * 流水类型
     */
    private AccountTradeTypeEnum tradeType;

    //======================= Methods =======================
    public static ContactorTradeDto buildFromIncomeDto(ContactorIncomeDto contactorIncomeDto) {
        ContactorTradeDto contactorTradeDto = new ContactorTradeDto();
        contactorTradeDto.setBalanceAccount(contactorIncomeDto.getBalanceAccount());
        contactorTradeDto.setAmount(contactorIncomeDto.getAmount());
        contactorTradeDto.setBusinessType(contactorIncomeDto.getBusinessType());
        contactorTradeDto.setBusinessBillId(contactorIncomeDto.getBusinessBillId());
        contactorTradeDto.setFeeIncurredTime(contactorIncomeDto.getFeeIncurredTime());
        contactorTradeDto.setTradeType(AccountTradeTypeEnum.INCOME);
        return contactorTradeDto;

    }

    public static ContactorTradeDto buildFromExpensesDto(ContactorExpensesDto contactorExpensesDto) {
        ContactorTradeDto contactorTradeDto = new ContactorTradeDto();
        contactorTradeDto.setBalanceAccount(contactorExpensesDto.getBalanceAccount());
        contactorTradeDto.setAmount(contactorExpensesDto.getAmount());
        contactorTradeDto.setBusinessType(contactorExpensesDto.getBusinessType());
        contactorTradeDto.setBusinessBillId(contactorExpensesDto.getBusinessBillId());
        contactorTradeDto.setFeeIncurredTime(contactorExpensesDto.getFeeIncurredTime());
        contactorTradeDto.setTradeType(AccountTradeTypeEnum.EXPENSES);
        return contactorTradeDto;
    }
}
